<template>
  <div class="box">
    <div class="box-left">
      <ul>
        <li class="item">
          <router-link to="/" class="login-item">首页</router-link>
        </li>
        <li class="item">
          
            <router-link to="/newlist" class="login-item">精品推荐</router-link>
          
        </li>
        <li class="item">
          <router-link to="/booklist" class="login-item">珍藏书单</router-link>
        </li>
        <li class="item">
          <router-link to="/bestwords" class="login-item">佳句赏析</router-link>
        </li>
        <li class="item">
          <router-link to="/wechat" class="login-item">畅所欲言</router-link>
        </li>
      </ul>
    </div>
    <div class="box-right">
      <div class="login" v-if="!token">
        <span class="item">
          <router-link to="/myregister" class="login-item">注册</router-link>
        </span>
        <span class="item">
          <router-link to="/mylogin" class="login-item">登录</router-link>
        </span>
      </div>
      <div class="login-successful" v-if="token">
        <router-link to="/myspace/myindex" class="left">
          <img src="/IMG/touxiang/lx.webp" alt="" />
          <span>刘小怂</span>
        </router-link>
        |
        <span class="right" @click="tuichu">退出</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      token: localStorage.getItem("token"),
    };
  },
  methods: {
    // 退出
    tuichu: function () {
      //退出登录，清空token
      localStorage.removeItem("token");
      this.$router.push("/mylogin");
    },
  },
};
</script>

<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
}
*a {
  user-select: none;
  text-decoration: none;
}
*li {
  list-style: none;
}
.item:hover {
  border-top: 2px solid red;
  background: #333;
}
.box {
  width: 1200px;
  margin: 0 auto;
  height: 65px;
  background-color: #666;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.box-left {
  width: 1000px;
  height: 65px;
  justify-content: space-around;
  align-items: center;

  ul {
    display: flex;
    justify-content: space-around;

    li {
      width: 250px;
      // height: 65px;
      line-height: 65px;
      text-align: center;
      margin: 0 auto;

      a {
        color: aliceblue;
        font-size: 1.3rem;
      }
    }
  }
}
.box-right {
  width: 200px;
  // height: 65px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.login-successful {
  display: flex;
  justify-content: space-around;
  align-items: center;
  color: white;
  .left {
    display: flex;
    align-items: center;
    img {
      width: 35px;
      height: 35px;
      border-radius: 50%;
    }
    > span {
      margin: 0 10px;
      color: white;
      &:hover {
        font-weight: 900;
      }
    }
  }
  .right {
    margin-left: 10px;
    &:hover {
      font-weight: 900;
    }
  }
}
.login {
  width: 200px;
  // height: 65px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  > span {
    border-radius: 5px;
    padding: 5px 5px;
    background-color: #46aaff;
    display: flex;
    .login-item {
      font-size: 1.3rem;
      width: 60px;
      height: 30px;
      color: white;
      text-align: center;
    }
  }
}
</style>
